package com.blrs.service.process.impl;

import java.util.List;
import java.util.Date;

import com.blrs.common.utils.uuid.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.blrs.mapper.StageAchievementMapper;
import com.blrs.domain.StageAchievement;
import com.blrs.service.process.IStageAchievementService;
import com.blrs.common.utils.SecurityUtils;

@Service
public class StageAchievementServiceImpl implements IStageAchievementService {
    @Autowired
    private StageAchievementMapper stageAchievementMapper;

    @Override
    public StageAchievement selectStageAchievementById(String id) {
        return stageAchievementMapper.selectStageAchievementById(id);
    }

    @Override
    public List<StageAchievement> selectStageAchievementList(StageAchievement stageAchievement) {
        return stageAchievementMapper.selectStageAchievementList(stageAchievement);
    }

    @Override
    public List<StageAchievement> selectStageAchievementsByStageId(String templateId ,String stageId) {
        return stageAchievementMapper.selectStageAchievementsByStageId(templateId,stageId);
    }

    @Override
    @Transactional
    public int insertStageAchievement(StageAchievement stageAchievement) {
        stageAchievement.setId(UUID.randomUUID().toString());
        stageAchievement.setCreationId(SecurityUtils.getUserId());
        stageAchievement.setCreationName(SecurityUtils.getUsername());
        stageAchievement.setCreationTime(new Date());
        return stageAchievementMapper.insertStageAchievement(stageAchievement);
    }

    @Override
    @Transactional
    public int updateStageAchievement(StageAchievement stageAchievement) {
        stageAchievement.setUpdateId(SecurityUtils.getUserId());
        stageAchievement.setUpdateName(SecurityUtils.getUsername());
        stageAchievement.setUpdateTime(new Date());
        return stageAchievementMapper.updateStageAchievement(stageAchievement);
    }

    @Override
    @Transactional
    public int deleteStageAchievementByIds(String[] ids) {
        return stageAchievementMapper.deleteStageAchievementByIds(ids);
    }

    @Override
    @Transactional
    public int deleteStageAchievementById(String id) {
        return stageAchievementMapper.deleteStageAchievementById(id);
    }
} 